/**   
 * @Title: HemaiGetDetailCommunicater.java 
 * @Package com.esun.rabbit2.communicaters 
 * @Description: (通讯接口,业务标号10011) 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-7-4 下午02:27:38  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.HemaiDetailInfo;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: HemaiGetDetailCommunicater
 * @Description: (获取合买详细内容)
 * @author: City Jiangsy@500wan.com
 * @date: 2011-7-4 下午02:27:38
 * 
 */
public class HemaiGetDetailCommunicater extends ServerCommunicater {
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetDetailSucced(String lotId, String programId, String userName) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_HEMAI_DETIAL));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotId));
		list.add(mapItem(Key.KEY_PID, programId));
		list.add(mapItem(Key.KEY_USERNAME, userName));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public void updateHemaiDetailInfo() {
		HemaiDetailInfo.getHemaiDetailInfo().setAddTime(super.getListResult().get(0).get(Key.KEY_ADDTIME));
		HemaiDetailInfo.getHemaiDetailInfo().setAllCount(super.getListResult().get(0).get(Key.KEY_ANUMBER));
		HemaiDetailInfo.getHemaiDetailInfo().setAllMoney(super.getListResult().get(0).get(Key.KEY_ALLMONEY));
		HemaiDetailInfo.getHemaiDetailInfo().setBaodiMoney(super.getListResult().get(0).get(Key.KEY_BAODIMONEY));
		HemaiDetailInfo.getHemaiDetailInfo().setBeishu(super.getListResult().get(0).get(Key.KEY_BEISHU));
		HemaiDetailInfo.getHemaiDetailInfo().setEachMoney(super.getListResult().get(0).get(Key.KEY_ONEMONEY));
		HemaiDetailInfo.getHemaiDetailInfo().setHitCount(super.getListResult().get(0).get(Key.KEY_LOTTERYCOUNT));
		HemaiDetailInfo.getHemaiDetailInfo().setHitMoney(super.getListResult().get(0).get(Key.KEY_LOTTERYMONERY));
		HemaiDetailInfo.getHemaiDetailInfo().setJindu(super.getListResult().get(0).get(Key.KEY_RENQI));
		HemaiDetailInfo.getHemaiDetailInfo().setLeftCount(super.getListResult().get(0).get(Key.KEY_LEFTNUMBER));
		HemaiDetailInfo.getHemaiDetailInfo().setProgramContent(super.getListResult().get(0).get(Key.KEY_FILEORCODE));
		HemaiDetailInfo.getHemaiDetailInfo().setIsShow(super.getListResult().get(0).get(Key.KEY_ISSHOW));
		if (super.getListResult().get(0).get(Key.KEY_ISMANYUAN).equals(Config.NUM1)) {
			HemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_MANYUAN);
		} else {
			HemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_WEIMANYUAN);
		}
		HemaiDetailInfo.getHemaiDetailInfo().setStrFaqiren(super.getListResult().get(0).get(Key.KEY_USERNAME));
		HemaiDetailInfo.getHemaiDetailInfo().setTicheng(super.getListResult().get(0).get(Key.KEY_TICHENG));
		HemaiDetailInfo.getHemaiDetailInfo().setIsUpload(super.getListResult().get(0).get(Key.KEY_ISUPLOAD));
		HemaiDetailInfo.getHemaiDetailInfo().setIsChaser(super.getListResult().get(0).get(Key.KEY_ISCHASER));
	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
